const wxParse = require("../../components/wxParse/wxParse.js")
var app = getApp()
Page({
    data: {
        code: 0
    },

    onLoad(options) {
        var that = this
        that.setData({
            id: options.id || 0,
        },() => {
            that.getdata()
        })
    },

    getdata() {
        var that = this
        const { id } = that.data
        const data = { id }
        //console.log(data)
        app.api_request('?c=cpage_detail','GET',data).then(function (res) {
            if (res) {
                that.setData({
                    code: 1,
                    pagedata: res
                })
                app.api_request('?c=cpage_detail_content','GET',data).then(function (res) {
                    wxParse.wxParse('cpage_detail_content','html',res,that,5)
                })
                tt.setNavigationBarTitle({
                    title: res.appTitle
                })
            }
        })
    },

    showImage(e) {
        const { images } = e.currentTarget.dataset
        let src = e.currentTarget.dataset.src
        // console.log(images)
        // console.log(src)
        tt.previewImage({
            current: src,
            urls: images
        })
    },

    onShareAppMessage: function () {
        var that = this
        return {
            title: that.data.pagedata.appTitle,
            desc: that.data.pagedata.appDesc,
            imageUrl: that.data.pagedata.thumb,
            path: '/pages/cpage/detail?id=' + that.data.pagedata.id
        }
    }
})